#include "loger.h"
#include "loger_inner.h"
#include "bsp_usart1.h"
#if (CONFIG_OS_ENABLE == 1)
#include "os_sal.h"
#endif



/* static var */

#if (CONFIG_OS_ENABLE == 1)
static os_mutex_handle_t loger_mutex = NULL;
#endif

/* export func */


int loger_port_init(void)
{
#if (CONFIG_OS_ENABLE == 1)
    loger_mutex = os_mutex_create();
    if (loger_mutex == NULL)
    {
        return -1;
    }
#endif

    return 0;
}

int loger_port_output(const char *log, uint32_t size)
{
    return bsp_usart1_send_buff((uint8_t*)log, size);
}

void loger_port_lock(void)
{
#if (CONFIG_OS_ENABLE == 1)
    os_mutex_take(loger_mutex, OS_WAIT_MAX);
#endif
}

void loger_port_unlock(void)
{
#if (CONFIG_OS_ENABLE == 1)
    os_mutex_release(loger_mutex);
#endif
}




